<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <%--多附件上传css--%>
    <link rel="stylesheet" href="<s:url value="/assets/css/main.css"></s:url>"/>
</head>
<style>
    body{
        background: #fff;
    }
    .SelectFiles{
        display: inline-block;
        position: absolute;
        font-size: 14px;
        color: #fff;
        left: 23px;
        top: 5px;
        width: 76px;
        height: 27px;
        background: #6FB3E0;
        text-align: center;
        border-radius: 5px;
        line-height: 25px;
        cursor: pointer;
    }
    button.btn{
        border-radius: 5px;
    }
    #laydate_today{
        display: none !important;
    }
    .select2-container .select2-choice{
        height: 34px;
        line-height: 34px;
        border-radius: 0px  !important;
    }
    .select2-container .select2-choice .select2-arrow b:before{
        left: 4px;
        top: -5px;
    }
</style>
<script>
</script>
<body>
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>
<h5 class="redTips col-sm-offset-2">温馨提示：红色星号为必填项</h5>
<form:form commandName="taskMain" cssClass="form-horizontal" role="form" onsubmit="return false;" enctype="multipart/form-data" id="updateForm" action="/taskMain/createTask/">
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label redTips">任务名称</label>
        <div class="col-sm-8">
            <textarea rows="2"  placeholder="请输入任务名称" class="form-control" id="mainName" name="mainName" readonly >${taskMain.mainName}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">任务内容</label>
        <div class="col-sm-8">
            <textarea rows="2"  placeholder="请输入任务内容" class="form-control" name="content" readonly>${taskMain.content}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label redTips">事项类型</label>
        <div class="col-sm-8">
            <select class="form-control" onchange="TypesOfevents(this)" id="select1" name="categoryId">
                <option value="">点击选择</option>
                <c:forEach var="category" items="${categoryList}">
                    <option value="${category.sysId}">${category.category}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div id="symbol" style="display: none">
        <div class="form-group">
            <label class="col-sm-offset-1 col-sm-1 text-right control-label">文号</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" property="请输入文号" value="" name="fileNumber">
            </div>
        </div>
    </div>
    <div id="major" style="display: none">
        <div class="form-group">
            <label class="col-sm-offset-1 col-sm-1 text-right control-label">督办单位</label>
            <div class="col-sm-8">
                <select id="e2" name="overdueDept">
                    <option value=""></option>
                    <c:forEach items="${sysDeptList}" var="sysDept">
                        <option value="${sysDept.sysId}">${sysDept.deptName}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">时限类型</label>
        <div class="col-sm-4 timeTypes">
            <input type="radio" name="timeType" value="1">单时限
            <input type="radio" name="timeType" value="2">周期性
            <input type="radio" name="timeType" value="3">多时限
        </div>
    </div>
    <div class="choiceTime">
        <div class="form-group">
            <label class="col-sm-offset-1 col-sm-1 text-right control-label redTips">任务时限</label>
            <div class="col-sm-3 periods">
                <input type="radio" name="period" value="1">周
                <input type="radio" name="period" value="2">月
                <input type="radio" name="period" value="3">季度
            </div>
            <label  class="col-sm-1 text-right control-label">反馈时限</label>
            <div class="col-sm-4 feedbackTime"></div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">协办提前天数</label>
        <div class="col-sm-8">
            <input type="number" class="form-control" value="0" min="0" name="lessDays" placeholder="请输入协办提前天数">
        </div>
    </div>
   <%-- <div class="form-group">
        <c:if test="${empty taskMain.gJFile}">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">攻坚任务附件</label>
            <div class="col-sm-8 pos-rel">
                <input type="text" class="form-control" readonly value="无附件">
            </div>
        </c:if>
        <c:if test="${!empty taskMain.gJFile}">
            <label class="col-sm-offset-1 col-sm-1 text-right control-label">攻坚任务附件</label>
            <div class="col-sm-8 pos-rel">
                <input type="text" readonly name="gJFileName" value="${taskMain.gJFileName}">
                <input type="hidden" readonly name="gJFile" value="${taskMain.gJFile}">
                <button class="btn btn-primary" FileSysId="${taskMain.gJFile}" onclick="download(this)">
                    下载附件
                </button>
            </div>
        </c:if>
    </div>--%>
    <%--循环附件下载--%>
    <div class="form-group">
        <label class="control-label col-sm-offset-1 col-sm-1">攻坚任务附件:</label>
        <div class="col-sm-9">
            <c:if test="${not empty taskMain.gJFile}">
                <c:forEach items="${taskMain.gJFile}" var="fileMap">
                    <div style="margin-bottom:15px;">
                        <input style="width: 70%;" type="text" class="fileName" readonly
                               title="${fileMap.fileName}"
                               value="${fileMap.fileName}" onclick="copyFile(this)">
                        <button class="btn btn-primary file" onclick="download(this)"
                                FileSysId="${fileMap.file}">
                            下载附件
                        </button>
                    </div>
                </c:forEach>
            </c:if>
            <c:if test="${empty taskMain.gJFile}">
                <input type="text" value="无附件" class=" col-sm-3 form-control" readonly>
            </c:if>
        </div>
    </div>
    <%-----以上为附件下载----%>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">任务附件</label>
        <div class="col-sm-8 pos-rel">
            <div id="uploader"></div>
            <%--<div>--%>
                <%--<div style="display: inline-block">--%>
                    <%--<input type="file" class="fileBorder" id="fileupload">--%>
                <%--</div>--%>
                <%--<div style="display: inline-block">--%>
                    <%--<button class="btn btn-info" onclick="uploadFile(this,'file','fileName')">--%>
                        <%--<span class="glyphicon glyphicon-open"></span>上传附件--%>
                    <%--</button>--%>
                <%--</div>--%>
            <%--</div>--%>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">审批</label>
        <div class="col-sm-8">
            <select class="form-control" name="auditorId">
                <option value="">点击选择</option>
                <c:forEach var="leader" items="${leaderList}">
                    <option value="${leader.sysId}">${leader.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-offset-1 col-sm-1 text-right control-label">抄送</label>
        <div class="col-sm-8">
            <select multiple="true" id="e1" name="copeToIds" onchange="CC(this)">
                <option></option>
                <c:forEach items="${copeToList}" var="copeTo">
                    <option value="${copeTo.sysId}">${copeTo.name}</option>
                </c:forEach>
            </select>
            <input type="hidden" value="" name="">
        </div>
    </div>
    <h5 class=" col-sm-offset-2 col-sm-8">
        <p class="redTips">温馨提示：请手动添加任务或者导入任务</p>
        <p class="redTips">温馨提示：导入任务时单位名称必须严格按照OA发文单的单位名称填写，多个单位之间使用中文顿号分隔，任务单位区分牵头和协办的中间使用中文逗号分隔；任务时限按xxxx-xx-xx的格式填写；多个抄送领导之间使用中文顿号分隔（任务时限和抄送领导为选填）。</p>
    </h5>
    <div class="form-group">
        <div class="col-sm-1 col-sm-offset-2">
            <button class="btn btn-info redTips btn-sm" onclick="addDeparts()"><span class="glyphicon glyphicon-plus"> </span> 添加任务</button>
        </div>
        <div class="col-sm-1">
            <input type="file" class="form-control" id="btn-Excel" style="display: none">
            <button class="btn btn-info redTips btn-sm" id="displayExcel" onclick="document.getElementById('btn-Excel').click()">
                <span class="glyphicon glyphicon-floppy-open"> </span> 导入任务
            </button>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-info upload-btn btn-sm"><span class="glyphicon glyphicon-floppy-save"></span>下载Excel模板</button>
        </div>
    </div>
    <div id="subContent"></div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-2">
            <input type="button" id="updateFormButton" class="btn-sm btn-success btn" value="确定提交" style="border-radius: 5px">
        </div>
    </div>
    <input type="hidden" name="sysId" value="${taskMain.sysId}">
    <input type="hidden" name="crucialUser" value="${taskMain.crucialUser}">
    <%--  type ==2 单位完成督查组的待立项 type==1 或不传为 督查组完成 攻坚办的待立项  提交时 单位 updateTaskUnit  督查组 updateTask 其他不变  --%>
    <input type="hidden" name="type" value="${type}">
    <%--多附件上传的name和id--%>
    <input type="text" name="file" value="" >
    <input type="text" name="fileName" value="" >
</form:form>
<%--多选上传--%>
<script src="<s:url value="/assets/js/dist/easyUploader.jq.js"></s:url>"></script>
<script src="<s:url value="/assets/js/chosen.jquery.js"></s:url>"></script>
<script src="<s:url value="/assets/js/modal/modal.js"></s:url>"></script>
<script src="<s:url value="/assets/js/select2.js"></s:url>"></script>
<script src="<s:url value="/assets/laydate/laydate.dev.js"></s:url>"></script>
<script src="<s:url value="/assets/js/jquery.gritter.js"></s:url>"></script>
<script src="<s:url value="/assets/js/own.js"></s:url>"></script>

<script>
    <%--多文件上传--%>
    var fileStr = "";//id字符串拼接
    var fileNameStr = "";//文件名字符串拼接
    var uploader = easyUploader({
        id: "uploader",
        accept: '.jpg,.png,.doc,.docx,.pdf,.xls,.xlsx,.ppt,.pptx',
        action: '/filesUpload/uploadFiles',
        dataFormat: 'formData',
        maxCount: 10,//允许上传的个数
        maxSize: 2000,//允许上传最大的容量
        multiple: true,
        data: null,
        beforeUpload: function (file, data, args) {
        },
        onChange: function (fileList) {
        },
        onRemove: function (removedFiles, files) {
            console.log('onRemove', removedFiles);
        },
        onSuccess: function (res) {
            console.log('onSuccess', res);
            if (res.data !== undefined && res.data[0] !== undefined) {
                //拼接文件id 和 文件名
                $("input[name='file']").val(fileStr += res.data[0].sysid + ",");
                $("input[name='fileName']").val(fileNameStr += res.data[0].oldName + ",");

            }
        },
        onError: function (err) {
            console.log('onError', err);
        },
    });
</script>
<script type="text/javascript">
    function minDate() {
        var now = new Date();
        return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + (now.getDate() + 1);
    }
    $(document).ready(function (){
        $(document).on("click",".date_picker",function () {
            laydate({
                elem: this,
                min: minDate(),
                choose:function (taskTime) {  //单时限  日期换天数
                    //获取到当天日期
                    var date = new Date();
                    var seperator1 = "-";
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var strDate = date.getDate();
                    if (month >= 1 && month <= 9) {
                        month = "0" + month;
                    }
                    if (strDate >= 0 && strDate <= 9) {
                        strDate = "0" + strDate;
                    }
                    var currentdate = year + seperator1 + month + seperator1 + strDate;
                    // console.log(currentdate);
                    // console.log55555

                    //获取任务时限的val值 计算出任务与时限相差几天
                    var disparity = ((new Date(taskTime)/1000) - (new Date(currentdate)/1000))/(60*60*24);
                    $("#date_picker_jy").val(disparity);
                }
            });
        });
        $(document).on("click","#date_picker",function () {
            laydate({
                elem: "#date_picker",
                format: 'YYYY-MM-DD',
                // min: minDate(),
                choose: function(data){
                    //将值赋值给input框
                    var $checked = $("input[name='period']:checked").val();
                    data = data.substring(data.length-2)
                    $("#date_picker").val(data);
                }
            });
        });
        $("#e1").select2({
            placeholder: "请输入或点击选择抄送对象",
            width: "100%",
            closeOnSelect: false,
            allowClear: true,
        });
        $("#e2").select2({
            placeholder: "请输入或点击选择督办单位",
            width: "100%",
        });
        $(".e2").select2({
            placeholder: "请输入或点击选择牵头单位",
            width: "100%",
            closeOnSelect: false,
            allowClear: true,
        });
        $(".e22").select2({
            placeholder: "请输入或点击选择协办单位",
            width: "100%",
            closeOnSelect: false,
            allowClear: true,
        });
    });
    $(" .SelectFiles").click(function () {
        var $this = $(this);
        $this.siblings().val()
    })

    function TypesOfevents(data) {
        /*议题*/
        if ($(data).val() == "20190807100000000001"){
            $("#symbol").show()
        }else {
            $("#symbol").hide().find("input[name='fileNumber']").val(" ");
        }
        /*重大*/
        if ($(data).val() == "20190919100000000001"){
            $("#major").show()
        }else {
            $("#major").hide();
            $("#e2").select2('val', "");
        }
    }

    /**
     *  导入Excel
     */
    $(document).on('change', "#btn-Excel",function () {
        var $this = $(this);
        var slgBtn = $(this).siblings("button")
        var file = $(this).val();
        var formData = new FormData();
        formData.append("excelFile", $("#btn-Excel")[0].files[0]);
        $(".shade").fadeIn(100);
        $(".warning").fadeIn(100);
        $('.la-square-jelly-box').show();
        showShade();
        //警告框自定义内容
        $('.warning>.title>em').html('加载中……');
        if(file){
            $.ajax({
                url: "/taskMain/taskExcel",
                data: formData,
                type: "post",
                processData: false,
                contentType: false,
                success: function(data) {
                    $('.warning>.title>em').html(data);
                    $this.remove();
                    slgBtn.before(
                        "<input type=\"file\" class=\"form-control\" id=\"btn-Excel\" style=\"display: none\">"
                    )
                }
            });
        }else {
            alert("导入失败")
        }
    });

    /**
     * 获取牵头单位  获县领导列表
     *
     */
    var danwei = "";
    var xianlingdao = "";
    var danweiArr = [];

    var  i = 0;
    /**
     * 添加任务
     */
    function addDeparts(){
        danwei = "";
        xianlingdao = "";
        danweiArr = [];
        var deptSysId = $("#e2 option:selected").val();
        (function () {
            $.ajax({
                type:"POST",
                data:{deptId:deptSysId},
                url:"/taskMain/cbDeptList/",
                async:false,
                success:function (data) {
                    for (var i = 0; i<data.length; i++){
                        danwei += " <option value=\""+ data[i].sysId +"\">"+data[i].deptName +"</option>";
                        danweiArr.push({danweiSysId:data[i].sysId,danweiName:data[i].deptName});
                    }
                }
            })
            $.ajax({
                url:"/taskMain/leaderList/",
                async:false,
                success:function (data) {
                    for (var i = 0; i<data.length;i++ ){
                        xianlingdao += " <option value=\""+ data[i].sysId +"\">"+data[i].name +"</option>";
                    }
                }
            })
        })();
        var html = "";
        html += "" +
            " <div>\n" +
            "        <div class=\"form-group\">\n" +
            "            <label class=\"col-sm-offset-1 col-sm-1 text-right control-label\"><span style=\"color: red;\">*</span> 子事项</label>\n" +
            "            <div class=\"col-sm-7\">\n" +
            "                <input type=\"text\" name=\"taskSubFilterList["+ i +"].subName\" class=\"form-control\" placeholder=\"请输入子事项\">\n" +
            "            </div>\n" +
            "            <div class=\"col-sm-1\">\n" +
            "                <button class=\"btn-sm btn-danger\" id='deltask'>删除任务</button>\n" +
            "            </div>\n" +
            "        </div>\n" +
            "        <div class=\"form-group\">\n" +
            "            <label class=\"col-sm-offset-1 col-sm-1 text-right control-label\"><span style=\"color: red;\">*</span>牵头单位</label>\n" +
            "            <div class=\"col-sm-7\">\n" +
            "                <select multiple=\"true\"  class=\"e"+i+"\" onchange='Monitor(this)'> "+ danwei + "</select>\n" +
            "               <input type='hidden' value='' name=\"taskSubFilterList["+ i +"].leadDeptIds\">\n" +
            "            </div>\n" +
            "        </div>\n" +
            "        <div class=\"form-group\">\n" +
            "            <label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">协办单位</label>\n" +
            "            <div class=\"col-sm-7\">\n" +
            "                <select multiple=\"true\" class=\"e"+i+i+" xieban\" onchange='Monitor1(this)'></select>\n" +
            "               <input type='hidden' value='' name=\"taskSubFilterList["+ i +"].assistDeptIds\">\n" +
            "            </div>\n" +
            "        </div>\n" +
            "        <div class=\"form-group\">\n" +
            "            <label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">任务时限</label>\n" +
            "            <div class=\"col-sm-7\">\n" +
            "        <input type=\"text\" readonly name=\"taskSubFilterList["+ i +"].subTimeLimit\" id=\"date_picker"+ i +"\" lay-verify=\"date\" placeholder=\"年-月-日\" autocomplete=\"off\" class=\"layui-input form-control date_picker\">\n" +
            "            </div>\n" +
            "        </div>\n" +
            "        <div class=\"form-group\">\n" +
            "            <label class=\"col-sm-offset-1 col-sm-1 text-right control-label\">抄送</label>\n" +
            "            <div class=\"col-sm-7\">\n" +
            "                <select multiple=\"true\" id=\"e1\" name=\"\" class=\"caosong"+ i +"\" onchange=\"CC(this)\">"+ xianlingdao +"</select>\n" +
            "                    <input type=\"hidden\" value=\"\" name=\"taskSubFilterList["+ i +"].subCopeToIds\">\n" +
            "                </div>\n" +
            "           </div>" +
            "    </div>"
        $('#subContent').append(html);
        $(".e"+i+"").select2({
            placeholder: "请输入或点击选择牵头单位",
            width: "100%",
            closeOnSelect: false,
            allowClear: true,
        });
        $(".e"+i+i+"").select2({
            placeholder: "请先选择牵头单位",
            width: "100%",
            closeOnSelect: false,
            allowClear: true,
        });
        $(".caosong"+ i +"").select2({
            placeholder: "请输入或点击选择抄送对象",
            width: "100%",
            closeOnSelect: false,
            allowClear: true,
        });
        i++
    }
    function Monitor(data)  {
        var $data = $(data).val();
        //临时数组存放
        var tempArray1 = []; //临时数组1
        var tempArray2 = []; //临时数组2
        for (var i = 0; i < $data.length; i++) {
            tempArray1[$data[i]] = true; //将数array2 中的元素值作为tempArray1 中的键，值为true；
        }
        for (var i = 0; i < danweiArr.length; i++) {
            if (!tempArray1[danweiArr[i].danweiSysId]) {
                tempArray2.push(danweiArr[i]); //过滤array1 中与array2 不相同的元素；
            }
        }
        var xieban;
        for (var i = 0; i<tempArray2.length; i++){
            xieban +=  " <option value=\""+ tempArray2[i].danweiSysId +"\">"+tempArray2[i].danweiName +"</option>"
        }
        $(data).parent().parent().siblings().find("select.xieban").html(xieban);
        $(data).siblings("input").val($(data).val().join(","));
    }
    function Monitor1(data) {
        $(data).siblings("input").val($(data).val().join(","));
    }
    function CC(data) {
        $(data).siblings("input").val($(data).val().join(","));
    }

    /**
     * 删除任务
     */
    $(document).on('click','#deltask',function(){
        var $this = $(this);
        console.log($this);
        $this.parent().parent().parent().remove()
    })

    /**
     * timeLimit  时限 changeTime date_picker_jy
     */
    $(document).on("blur","#date_picker_jy",function () {
        var $this = $(this)
        var time = $this.val();
        $.ajax({
            url:"/taskMain/changeTime/",
            type:"post",
            data:{day:time},
            success:function (data) {
                $this.parent().prev().prev().children("input").val(data);
            }
        })
    })
    /**
     * 下载Excel模板
     */
    $(".upload-btn").on("click", function () {
        window.open("/taskMain/downModel/");
    })

    /**
     *  时限类型 默认选中
     */
    function selectionTime($checked = 1){
        var html = ""
        if ($checked == 1){
            html = "<div class='form-group'>" +
                "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label redTips\">任务时限</label>\n" +
                "    <div class=\"col-sm-4\">\n" +
                "        <input type=\"text\" class=\"form-control date_picker\" name=\"timeLimit\" readonly>\n" +
                "    </div>\n" +
                "    <label class=\"col-sm-1 text-right control-label \">任务天数</label>\n" +
                "    <div class=\"col-sm-3\">\n" +
                "        <input type=\"text\" class=\"form-control\" id=\"date_picker_jy\">\n" +
                "    </div>\n" +
                "    </div>"
        }else if ($checked == 2){
            html =  "<div class='form-group'>" +
                "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label redTips\">任务时限</label>\n" +
                "    <div class=\"col-sm-3 periods\">\n" +
                "        <input type=\"radio\" name=\"period\" value=\"0\">天\n" +
                "        <input type=\"radio\" name=\"period\" value=\"1\">周\n" +
                "        <input type=\"radio\" name=\"period\" value=\"2\">月\n" +
                "        <input type=\"radio\" name=\"period\" value=\"3\">季度\n" +
                "    </div>\n" +
                "    <label  class=\"col-sm-1 text-right control-label\">反馈时限</label>\n" +
                "    <div class=\"col-sm-4 feedbackTime\">\n" +
                "        <input type=\"number\" min='0' class=\"form-control\"  name=\"day\" placeholder=\"请输入天数 \">\n" +
                "    </div>\n" +
                "    </div>"
        } else if ($checked ==3){
            html = "<div class='form-group'>" +
                "<label class=\"col-sm-offset-1 col-sm-1 text-right control-label redTips\">任务时限</label>\n" +
                "    <div class=\"col-sm-4\">\n" +
                "        <input type=\"text\" placeholder=\"年-月-日\" class=\"form-control date_picker\" readonly>\n" +
                "    </div>\n" +
                "    <div class=\"col-sm-1 addTime\">\n" +
                "        <input type=\"button\" class=\"btn btn-sm btn-success addTimeBtn\"  value=\"添加时限\">\n" +
                "        <input type=\"hidden\" name=\"timeLimits\">\n" +
                "    </div>\n" +
                "    </div>"
        }
        $(".choiceTime").html(html);
        $(".periods").children().eq(0).attr('checked', 'true');
    }

    function selectionPeriod($checked){
        var html = "";
        if ($checked == 0){
            html = "        <input type=\"number\" class=\"form-control\" min='0' name=\"day\" placeholder=\"请输入天数\">\n"
        }
        else if ($checked == 1){
            html = "      <select name=\"week\" class=\"form-control\">\n" +
                "            <option value=\"1\">星期一</option>\n" +
                "            <option value=\"2\">星期二</option>\n" +
                "            <option value=\"3\">星期三</option>\n" +
                "            <option value=\"4\">星期四</option>\n" +
                "            <option value=\"5\">星期五</option>\n" +
                "            <option value=\"6\">星期六</option>\n" +
                "            <option value=\"7\">星期日</option>\n" +
                "        </select>"
        } else if ($checked == 2){
            html = "<input type=\"text\" id=\"date_picker\" value=\"\" readonly lay-verify=\"date\" name=\"month\" placeholder=\"日\" autocomplete=\"off\" class=\"layui-input form-control\">\n"
        }else if($checked == 3){
            html = "    <input type=\"text\" value=\"\" readonly lay-verify=\"date\" placeholder=\"年-月-日\" name=\"quarter\" autocomplete=\"off\" class=\"layui-input form-control date_picker\">\n"
        }
        $(".feedbackTime").html(html);
    }
    selectionTime();
    $(".timeTypes").children().eq(0).attr('checked', 'true');
    $(".timeTypes").on("click","input",function () {
        var $checked = $("input[name='timeType']:checked").val();
        selectionTime($checked);
    })
    $(document).on("click","input[name='period']",function () {
        var $checked = $("input[name='period']:checked").val();
        selectionPeriod($checked);
    })
    $(document).on("click",".addTimeBtn",function () {
        var html = " <div class=\"form-group\">" +
            "        <label class=\"col-sm-offset-1 col-sm-1 text-right control-label redTips\">任务时限</label>\n" +
            "   <div class=\"col-sm-4\">\n" +
            "       <input type=\"text\" value=\"\" readonly lay-verify=\"date\" placeholder=\"年-月-日\" autocomplete=\"off\" class=\"layui-input form-control date_picker\">\n" +
            "</div>\n" +
            "    <div class=\"col-sm-1 addTime\">\n" +
            "        <input type=\"button\" class=\"btn btn-sm btn-danger removeTimeBtn\"  value=\"删除时限\">\n" +
            "    </div>"
        "</div>"
        $(".choiceTime").append(html);
    });

    $(document).on("click",".removeTimeBtn",function () {
        $(this).parent().parent().remove();
    });

    //确认提交
    $("#updateFormButton").click(function () {
        failure("#updateFormButton",1);
        var value = []
        $(".choiceTime .date_picker").each(function() {
            value.push($(this).val());
        });
        value = value.join(",");
        $("input[name='timeLimits']").val(value);
        var userData = $("#updateForm").serialize();
        $.ajax({
            url:"/taskMain/updateTask/",
            data:userData,
            dataType:"text",
            type:"post",
            success:function (data) {
                data = JSON.parse(data);
                console.log(data.message)
                console.log(data)
                if (data.message == "保存成功") {
                    alert(data.message)
                    setTimeout(function () {
                        parent.close_current_app();
                    },50)
                } else {
                    alert(data.message)
                }
                failure("#updateFormButton",0);
            }
        });
        /**
         * 表单颜色的 form 提交
         */
        // $.post($form.attr('action'), $form.serialize(), function(result) {
        //     console.log(result);
        // });
    })

    //<input type="text" id="date_picker" value="" readonly lay-verify="date" placeholder="日" autocomplete="off" class="layui-input form-control">
    //mainName任务 select1事项    必填
</script>
</body>
</html>